package com.mingqijia.gassafety.shared.constant;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.mingqijia.gassafety.db.entity.Organization;
import com.mingqijia.gassafety.db.mapper.OrganizationMapper;
import com.mingqijia.gassafety.shared.utils.commonUtils.PageColumns;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.List;

@Component
public class PageColumnConst {

    @Autowired
    private OrganizationMapper organizationMapper;

    private static OrganizationMapper orgMapper;

    @PostConstruct
    public void init() {
        orgMapper = organizationMapper;
    }


    /**
     * 客户管理-列表 - 模板一
     */
    public static final String[]  gasConsumerListTitles = new  String[]{
        "客户ID","户号", "户名", "户址","户主手机号","客户名称","行业类型",
            "设备总数","点位总数","经纬度","客户来源","创建时间"
    };

    public static final String[]  gasConsumerListIndices = new  String[]{
        "idStr", "subsCode", "custName","custAddress","custPhone","name","industryType",
            "equipmentTotal","pointTotal","position","source","createdAt"
    };

    /**
     *  客户管理-列表 - 模板二
     */
    public static final String[]  asstConsumerListTitles = new  String[]{
            "客户ID", "用户ID", "用户手机号","行业类型","控制器数量","探头数量","经纬度","创建时间","燃气公司"
    };

    public static final String[]  asstConsumerListIndices = new  String[]{
            "idStr", "memberId", "phone","industryType","equipmentTotal","pointTotal","position","createdAt","companyName"
    };


    /**
     * 配置管理-通知记录
     */
    public static final String[]  gasWarningRecodeListTitles = new  String[]{
            "通知开始时间", "通知结束时间", "报警开始时间","通知对象","报警类型"
            ,"触发规则名称","设备号（IMEI）","设备名称","设备类型", "设备位置",
            "状态"
    };
    public static final String[]  gasWarningRecodeListIndices = new  String[]{
            "startTime", "endTime", "warningStartTime","consumerName","type",
            "ruleName","supIMEI","equipmentName","equipmentTypeName", "installationPosition",
            "status"
    };

    public static final String[]  asstWarningRecodeListTitles = new  String[]{
            "通知开始时间", "通知结束时间", "报警开始时间","通知对象","报警类型"
            ,"触发规则名称","设备号（IMEI）","设备名称","设备类型", "设备位置",
            "状态"
    };
    public static final String[]  asstWarningRecodeListIndices = new  String[]{
            "startTime", "endTime", "warningStartTime","memberInfo","type",
            "ruleName","supIMEI","equipmentName","equipmentTypeName", "installationPosition",
            "status"
    };

    /**
     * 客户列表 - 模板一
     */
    public static final String[]  gasCustListTitles = new  String[]{
                    "客户ID","户号", "户名"
            };

    public static final String[]  gasCustListIndices = new  String[]{
            "id", "subsCode", "custName"
    };

    /**
     * 客户列表 - 模板二
     */
    public static final String[]  asstCustListTitles = new  String[]{
            "用户ID","联系人姓名", "联系人手机号", "燃气公司"
    };

    public static final String[]  asstCustListIndices = new  String[]{
            "memberId", "contactName", "contactPhone", "companyName"
    };

    /**
     * 报警记录
     * 模板一（燃气用户）
     */
    public static final String[] AlertGasUserTitles =
            new String[]{"报警时间","报警持续时长","处理状态", "处理人","报警时气体浓度","电磁阀信息","设备号", "设备名称", "设备类型", "设备位置", "设备厂商", "设备型号",
                    "户名", "户号", "户主手机号", "户址", "行业类型"};

    public static final String[] AlertGasUserIndices =
            new String[]{"latestTime", "warnDuration","appealStatusMsg", "userInfo", "xlel","hasValve","imei", "equipmentName", "equipmentTypeName", "installationPosition",
                    "equipmentManufacturer", "equipmentModel", "custName", "subsCode", "custPhone", "custAddress", "industryTypeName"
            };
    /**
     * 报警记录
     * 模板二（Vcc用户）
     */
    public static final String[] AlertVccUserTitles =
            new String[]{"报警时间", "报警持续时长","处理状态", "处理人","报警时气体浓度","设备号", "设备名称", "设备类型", "设备位置",  "设备厂商", "设备型号",
                    "用户ID", "联系人姓名", "联系人电话", "安装地址", "行业类型"};

    public static final String[] AlertVccUserIndices =
            new String[]{"latestTime","warnDuration","appealStatusMsg", "userInfo", "xlel","imei", "equipmentName", "equipmentTypeName", "installationPosition",
                    "equipmentManufacturer", "equipmentModel", "memberId", "contactName", "contactPhone", "installationAddress", "industryTypeName"
            };
    /**
     * 故障记录
     * 模板一（燃气用户）
     */
    public static final String[] BrokenGasUserTitles =
            new String[]{"故障时间","处理状态", "处理人","故障原因","电磁阀信息","设备号", "设备名称","设备类型", "设备位置","设备厂商","设备型号",
                    "户名","户号","户主手机号","户址","行业类型"};

    public static final String[] BrokenGasUserIndices =
            new String[]{"latestTime","appealStatusMsg", "userInfo", "brokenReason","hasValve","imei", "equipmentName","equipmentTypeName","installationPosition",
                    "equipmentManufacturer", "equipmentModel","custName","subsCode","custPhone","custAddress",
                    "industryTypeName"
            };
    /**
     * 故障记录
     * 模板二（Vcc用户）
     */
    public static final String[] BrokenVccUserTitles =
            new String[]{"故障时间","处理状态", "处理人","故障原因","设备号", "设备名称","设备类型", "设备位置","设备厂商","设备型号",
                    "用户ID","联系人姓名","联系人电话","安装地址","行业类型"};

    public static final String[] BrokenVccUserIndices =
            new String[]{"latestTime","appealStatusMsg", "userInfo","brokenReason","imei", "equipmentName","equipmentTypeName","installationPosition",
                    "equipmentManufacturer", "equipmentModel","memberId","contactName","contactPhone","installationAddress", "industryTypeName"
            };

    /**
     * 复位记录
     * 模板一（燃气用户）
     */
    public static final String[] ResetGasUserTitles =
            new String[]{"复位时间","设备号", "设备名称","设备类型", "设备位置","设备厂商","设备型号",
                    "燃气公司","户名","户号","户主手机号","户址","行业类型"};

    public static final String[] ResetGasUserIndices =
            new String[]{"latestTime", "imei", "equipmentName","equipmentTypeName","installationPosition",
                    "manufactureName", "equipmentModel","companyName","custName","subsCode","custPhone","custAddress", "industryTypeName"
            };
    /**
     * 复位记录
     * 模板二（Vcc用户）
     */
    public static final String[] ResetVccUserTitles =
            new String[]{"复位时间","设备号", "设备名称","设备类型", "设备位置","设备厂商","设备型号",
                    "用户ID","联系人姓名","联系人电话","安装地址","行业类型"};


    public static final String[] ResetVccUserIndices =
            new String[]{"latestTime", "imei", "equipmentName","equipmentTypeName","installationPosition",
                    "manufactureName", "equipmentModel","memberId","contactName","contactPhone","installationAddress",
                    "industryTypeName"
            };

    /**
     * 开关机记录
     * 模板一（燃气用户）
     */
    public static final String[] PowerGasUserTitles =
            new String[]{"开关机时间","设备号", "设备名称","设备类型", "设备位置","事件","设备厂商","设备型号",
                    "燃气公司","户名","户号","户主手机号","户址","客户地址","行业类型"};

    public static final String[] PowerGasUserIndices =
            new String[]{"latestTime", "imei", "equipmentName","equipmentTypeName","installationPosition",
                    "startup","manufactureName", "equipmentModel","companyName","custName","subsCode","custPhone","custAddress","customerAddress", "industryTypeName"
            };
    /**
     * 复位记录
     * 模板二（Vcc用户）
     */
    public static final String[] PowerVccUserTitles =
            new String[]{"开关机时间","设备号", "设备名称","设备类型", "设备位置","事件","设备厂商","设备型号",
                    "用户ID","联系人姓名","联系人电话","安装地址","行业类型"};


    public static final String[] PowerVccUserIndices =
            new String[]{"latestTime", "imei", "equipmentName","equipmentTypeName","installationPosition",
                    "offline","manufactureName", "equipmentModel","memberId","contactName","contactPhone","installationAddress", "industryTypeName"
            };
    /**
     * 维护记录
     * 模板一（燃气用户）
     */
    public static final String[] MaintainGasUserTitles =
            new String[]{"填写时间","填写人", "所属部门","维保内容",
                    "户名","户号","户主手机号","户址","行业类型"};

    public static final String[] MaintainGasUserIndices =
            new String[]{"latestTime", "userName", "department","message",
                    "custName","subsCode","custPhone","custAddress", "industryTypeName"
            };
    /**
     * 维护记录
     * 模板二（Vcc用户）
     */
    public static final String[] MaintainVccUserTitles =
            new String[]{"填写时间","填写人", "所属部门","维保内容",
                    "用户ID","联系人姓名","联系人电话","安装地址","行业类型"};

    public static final String[] MaintainVccUserIndices =
            new String[]{"latestTime", "userName", "department","message",
                    "memberId","contactName","contactPhone","installationAddress", "industryTypeName"
            };

    /**
     * 报警策略
     * 模板一
     */
    public static final String[] StrategyTitles =
            new String[]{"规则名称","户名（户号）客户名称", "策略设备","规则状态", "报警值1","报警值2",
                    "更新时间","创建时间"};


    public static final String[] StrategyIndices =
            new String[]{"ruleName", "strategyObjValues", "strategyEquipment","isDisabled","lowReport",
                    "highReport","updatedAt","createdAt"};
    /**
     * 运行策略
     * 模板一
     */
    public static final String[] RunningStrategyTitles =
            new String[]{"规则名称","规则类型", "策略对象","规则状态", "更新时间","创建时间"};



    public static final String[] RunningStrategyIndices =
            new String[]{"ruleName", "strategyType", "strategyObjValues","isDisabled","updatedAt","createdAt"};
    /**
     * 报警策略
     * 模板二（Vcc用户）
     */
    public static final String[] StrategyVccTitles =
            new String[]{"规则名称","用户手机号（用户ID）", "策略设备","规则状态", "报警值1","报警值2",
                    "更新时间","创建时间"};


    public static final String[] StrategyVccIndices =
            new String[]{"ruleName", "strategyObjValues", "strategyEquipment","isDisabled","lowReport",
                    "highReport","updatedAt","createdAt"};

    /**
     * 报警数据
     * 模板一
     */
    public static final String[] WarningTitles =
            new String[]{"设备号（IMEI）","设备类型","安装位置","信息更新时间","报警时气体浓度",
                    "报警持续时长","外呼处理状态","处理时间","历史报警记录","报警策略","报警策略通知记录",
                    "设备厂商","设备型号","户名", "户号","户主手机号", "户址","行业类型"
            };



    public static final String[] WarningIndices =
            new String[]{"iMEI", "equipmentType", "installationPosition","warningStartTime","concentration",
                    "warningDuration","disposeStatus","disposeTime","record1","record2","record3",
                    "equipmentManufacturer","equipmentModel","custName", "subsCode","custPhone", "custAddress","industryType"};

    /**
     * 报警数据
     * 模板二（Vcc用户）
     */
    public static final String[] WarningVccTitles =
            new String[]{"设备号（IMEI）","设备类型","安装位置","信息更新时间","报警时气体浓度",
                    "报警持续时长","外呼处理状态","处理时间","历史报警记录","报警策略","报警策略通知记录",
                    "设备厂商","设备型号","用户ID", "联系人姓名","联系人手机号", "安装地址","行业类型","燃气公司"
                    };

    public static final String[] WarningVccIndices =
            new String[]{"iMEI", "equipmentType", "installationPosition","warningStartTime","concentration",
                    "warningDuration","disposeStatus","disposeTime","record1","record2","record3",
                    "equipmentManufacturer","equipmentModel","memberId", "name","phone", "address","industryType","companyName"};

    public static List<PageColumns> add(String[] titles , String[] indices){
        List<PageColumns> pageColumns = new ArrayList<>();
        for (int i = 0; i < titles.length; i++) {
            pageColumns.add(new PageColumns(titles[i],indices[i]));
        }
        return pageColumns;
    }

    public static List<PageColumns> add(String[] titles , String[] indices, String spId){
        List<PageColumns> pageColumns = new ArrayList<>();
        List<Organization> list = orgMapper.getList(spId);
        if (!CollectionUtils.isEmpty(list) ){
            pageColumns.add(new PageColumns("所属组织", "spName"));
        }
        for (int i = 0; i < titles.length; i++) {
            pageColumns.add(new PageColumns(titles[i],indices[i]));
        }
        return pageColumns;
    }

    public static List<PageColumns> add( String spId, String[] titles ,String[] indices){
        List<PageColumns> pageColumns = new ArrayList<>();
        List<Organization> list = orgMapper.getList(spId);
        for (int i = 0; i < titles.length; i++) {
            pageColumns.add(new PageColumns(titles[i],indices[i]));
        }
        if (!CollectionUtils.isEmpty(list) ){
            pageColumns.add(new PageColumns("所属组织", "spName"));
        }
        return pageColumns;
    }

    /**
     * 实时监测
     * 模板一（燃气用户）
     */
    public static final String[] LatestLogGasUserTitles =
            new String[]{"设备号（IMEI）","工单处理状态", "设备名称","设备类型", "设备位置","设备状态","设备状态说明","电磁阀信息",
                    "气体浓度","信号情况","信息更新时间","设备厂商","设备型号", "户名","户号","户主手机号","户址","行业类型","燃气公司"};

    public static final String[] LatestLogGasUserIndices =
            new String[]{"imei","handleStatus", "equipmentName", "equipmentTypeName","installationPosition","equipmentStatus",
                    "equipmentStatusInfo", "hasValve","xlel","signal","latestTime","equipmentManufacturer","equipmentModel",
                    "custName","subsCode","custPhone","custAddress", "industryTypeName","companyName"
            };
    /**
     * 实时监测
     * 模板二（Vcc用户）
     */
    public static final String[] LatestLogVccUserTitles =
            new String[]{"设备号（IMEI）","工单处理状态", "设备名称","设备类型", "设备位置","设备状态","设备状态说明",
                    "气体浓度","信号情况","信息更新时间","设备厂商","设备型号", "用户ID","联系人姓名","联系人电话","安装地址","行业类型"};

    public static final String[] LatestLogVccUserIndices =
            new String[]{"imei","handleStatus", "equipmentName", "equipmentTypeName","installationPosition","equipmentStatus",
                    "equipmentStatusInfo","xlel","signal","latestTime","equipmentManufacturer", "equipmentModel",
                    "memberId","contactName","contactPhone","installationAddress","industryTypeName"
            };

    /**
     * 历史工单
     * 模板一（燃气用户）
     */
    public static final String[] HistoryWorkOrderGasUserTitles =
            new String[]{"工单编号","业务类型", "发起渠道","发起时间", "作业系统","工单生成时间","工单完成时间","工单状态","处理结果"};

    public static final String[] HistoryWorkOrderGasUserIndices =
            new String[]{"orderNo","bizName", "fromSystemStr", "sendTime","workSystemStr","createTime",
                    "completedTime","orderStatusRemark","completeResult"};
    /**
     * 历史工单
     * 模板二（Vcc用户）
     */
    public static final String[] HistoryWorkOrderVccUserTitles =
            new String[]{"订单编号","工单编号","业务类型", "发起渠道","发起时间", "作业系统","工单生成时间","工单完成时间","工单状态","指派员工","处理结果"};

    public static final String[] HistoryWorkOrderVccUserIndices =
            new String[]{"outOrderCode","orderNo","bizName", "fromSystemStr", "sendTime","workSystemStr","createTime",
                    "completedTime","orderStatusRemark","servicerName","completeResult"};


    /**
     * 客户纬度- 历史关联记录, 模板二
     */
    public static final String[]  asstConsumerBindingHistoryTitles = new  String[]{
            "备注","操作时间","事件", "操作人","设备号(IMEI)","设备厂商","设备类型",
            "设备型号","检测类型","运营商", "通讯方式"
    };
    public static final String[] asstConsumerBindingHistoryIndices =
            new String[]{"outOrderCode","createdAt","event", "operationPersonName", "iMEI","equipmentManufacturer","equipmentType",
                    "equipmentModel","detectionType","operators","communicationMode"};

    /**
     * 客户纬度- 历史关联记录, 模板一
     */
    public static final String[]  gasConsumerBindingHistoryTitles = new  String[]{
            "操作时间","事件", "工单编号", "工单类型", "操作人", "渠道","设备号(IMEI)","安装日期","安装位置","设备厂商","设备类型",
            "设备型号","检测类型","运营商", "通讯方式"
    };
    public static final String[] gasConsumerBindingHistoryIndices =
            new String[]{"createdAt","event","workerOrderId", "orderType", "operationPersonName","bindChannel", "iMEI","installationPosition","installDate","equipmentManufacturer","equipmentType",
                    "equipmentModel","detectionType","operators","communicationMode"};


    /**
     * 电磁阀信息管理
     */
    public static final String[]  valveInfoListTitles = new  String[]{
            "电磁阀名称","电磁阀关联设备数", "电磁阀型号", "电磁阀材质","电磁阀厂家","电磁阀有效期","更新时间","创建时间"
    };
    public static final String[] valveInfoListIndices =
            new String[]{"valveName","equipmentCount", "valveModel","valveMaterial", "valveManufacturerName","valveValidity",
                    "updatedAt","createdAt"};


    /**
     * 设备运行记录
     */
    public static final String[] runningRecordTitles =
            new String[]{"通知时间", "通知方式","通知对象信息", "通知对象手机号","通知对象级别",
                    "发送结果" ,"内容"};

    public static final String[] runningRecordIndices =
            new String[]{"startTime", "sendType", "consumerInfo","pushPhone","objLevel",
                    "sendResult","content"};

    /**
     *  运行报告-列表
     */
    public static final String[]  runningReportListTitles = new  String[]{
            "客户ID", "户号", "户名","用户类型","设备类型","报告内容概要","报告内容","报告审核状态"
            ,"报告更新状态","报告更新时间","报告首次生成时间"
    };

    public static final String[]  runningReportListIndices = new  String[]{
            "consumerId", "subsCode", "custName","custType","deviceType","alarmProcessed","reportContentTypeName","checkStatusName"
            ,"updateStatusName","updatedAt","createdAt"
    };

}
